package com.leiduoduo.oms.service;

import com.leiduoduo.oms.dao.DishTypeDao;
import com.leiduoduo.oms.pojo.DishType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service
public class DishTypeServiceImpl implements DishTypeService {
    @Autowired
    DishTypeDao dishTypeDao;

    @Override
    public boolean addDishType(DishType dishType) {
        dishType.setCreated_at(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()))
                .setUpdated_at(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
        return dishTypeDao.addDishType(dishType);
    }

    @Override
    public boolean delDishType(DishType dishType) {
        dishType.setUpdated_at(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
        return dishTypeDao.delDishType(dishType);
    }

    @Override
    public boolean upDishType(DishType dishType) {
        dishType.setUpdated_at(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
        return dishTypeDao.upDishType(dishType);
    }

    @Override
    public DishType getDishTypeById(int id) {
        return dishTypeDao.getDishTypeById(id);
    }

    @Override
    public List<DishType> getDishTypeList() {
        return dishTypeDao.getDishTypeList();
    }

    @Override
    public List<DishType> getDishTypeByRestId(int restaurant_id) {
        return dishTypeDao.getDishTypeByRestId(restaurant_id);
    }
}
